package com.corona.game;

import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Vector2;
import com.corona.Game;

/* compiled from: Player.java */
/* loaded from: pokewilds.jar:com/pkmngen/game/DrawPlayerUpper.class */
public class DrawPlayerUpper extends Action {
    public static int offsetY = 0;
    public static int pokemonOffsetY = 0;
    public static boolean desertGrass = false;
    public static boolean drawTidal = false;
    public static int timer = 0;
    public Action.Layer layer = Action.Layer.map_115;
    Sprite spritePart = new Sprite();
    int fishingOffsetX = 0;
    int fishingOffsetY = 0;
    int floatOffset = 0;
    int floatTimer = 0;

    public DrawPlayerUpper() {
        super(new Object[0]);
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        if (!game.player.isSitting) {
            if (game.player.isSleeping) {
                if (game.player.sleepingDir == null) {
                    game.player.zSprite.draw(game.mapBatch);
                    game.mapBatch.draw(game.player.sleepingSprite, game.player.position.x, game.player.position.y);
                    return;
                }
                Vector2 pos = game.player.sleepingDir.cpy().sub(game.player.position);
                game.mapBatch.draw(game.player.zSprite, (game.player.zSprite.getX() + pos.x) - 12.0f, game.player.zSprite.getY() + pos.y + 16.0f);
                this.spritePart.set(game.player.currSprite);
                this.spritePart.setRegionY(game.player.spriteOffsetY);
                this.spritePart.setRegionHeight(6);
                game.mapBatch.draw(this.spritePart, game.player.sleepingDir.x, game.player.sleepingDir.y + 12.0f + 8.0f);
            } else if (!game.player.currFieldMove.equals("FLY")) {
                if (game.player.drawSleepingBag) {
                    game.mapBatch.draw(game.player.sleepingBagSprite, game.player.sleepingBagSprite.getX(), game.player.sleepingBagSprite.getY());
                }
                this.spritePart.set(game.player.currSprite);
                this.fishingOffsetX = 0;
                this.fishingOffsetY = 0;
                if (game.player.isFishing) {
                    if (game.player.dirFacing.equals("left")) {
                        this.fishingOffsetX = -8;
                    } else if (game.player.dirFacing.equals("down")) {
                        this.fishingOffsetY = -8;
                    }
                }
                if (desertGrass) {
                    this.spritePart.setRegionY(game.player.spriteOffsetY);
                    this.spritePart.setRegionHeight(((int) this.spritePart.getHeight()) - 3);
                    game.mapBatch.draw(this.spritePart, game.player.position.x + ((float) this.fishingOffsetX), game.player.position.y + 7.0f + ((float) pokemonOffsetY) + ((float) this.fishingOffsetY));
                } else if (drawTidal) {
                    this.spritePart.setRegionY(game.player.spriteOffsetY);
                    this.spritePart.setRegionHeight(((int) this.spritePart.getHeight()) - 3);
                    game.mapBatch.draw(this.spritePart, game.player.position.x + ((float) this.fishingOffsetX), game.player.position.y + 7.0f + ((float) pokemonOffsetY) + ((float) this.fishingOffsetY));
                } else if (!game.player.currFieldMove.equals("SURF") || game.player.hmPokemon == null) {
                    this.spritePart.setRegionY(game.player.spriteOffsetY);
                    this.spritePart.setRegionHeight(((int) this.spritePart.getHeight()) - 8);
                    game.mapBatch.draw(this.spritePart, game.player.position.x + ((float) this.fishingOffsetX), game.player.position.y + 12.0f + ((float) pokemonOffsetY) + ((float) this.fishingOffsetY));
                } else {
                    int offsetY2 = 0;
                    if (game.player.hmPokemon.specie.name.equals("lapras")) {
                        offsetY2 = 0 + 3;
                    } else if (game.player.hmPokemon.specie.name.equals("araichu")) {
                        offsetY2 = 0 + 3;
                    } else if (game.player.hmPokemon.specie.name.equals("raichu")) {
                        offsetY2 = 0 + 4;
                    } else if (game.player.hmPokemon.specie.name.equals("pikachu")) {
                        offsetY2 = 0 + 4;
                    } else if (game.player.hmPokemon.specie.name.equals("ludicolo")) {
                        offsetY2 = 0 - 3;
                    } else if (game.player.dirFacing.equals("left")) {
                        if (game.player.hmPokemon.specie.name.equals("feraligatr") || game.player.hmPokemon.specie.name.equals("kingdra")) {
                            offsetY2 = 0 + 2;
                        }
                    } else if (game.player.dirFacing.equals("right") && (game.player.hmPokemon.specie.name.equals("feraligatr") || game.player.hmPokemon.specie.name.equals("kingdra"))) {
                        offsetY2 = 0 + 2;
                    }
                    this.spritePart.setRegionHeight((((int) this.spritePart.getHeight()) - 6) + offsetY2 + this.floatOffset);
                    game.mapBatch.draw(this.spritePart, game.player.position.x, game.player.position.y + 4.0f);
                }
                if (game.player.currFieldMove.equals("RIDE") && game.player.hmPokemon != null) {
                    int offsetX = 0;
                    int offsetY3 = 0;
                    if (game.player.dirFacing.equals("up")) {
                        offsetY3 = 0 - 2;
                        if (game.player.hmPokemon.specie.name.equals("mamoswine")) {
                            offsetY3 += 5;
                        }
                        if (game.player.hmPokemon.specie.name.equals("probopass")) {
                            offsetY3 += 8;
                        }
                    }
                    if (game.player.dirFacing.equals("down")) {
                        offsetY3 += 3;
                        if (game.player.hmPokemon.specie.name.equals("ponyta") || game.player.hmPokemon.specie.name.equals("rapidash")) {
                            offsetY3--;
                        }
                        if (game.player.hmPokemon.specie.name.equals("mamoswine")) {
                            offsetY3 += 2;
                        }
                        if (game.player.hmPokemon.specie.name.equals("rhyhorn")) {
                            offsetY3++;
                        }
                        if (game.player.hmPokemon.specie.name.equals("probopass")) {
                            offsetY3 += 4;
                        }
                    } else if (game.player.dirFacing.equals("right")) {
                        offsetX = 0 - 4;
                        if (game.player.hmPokemon.specie.name.equals("ninetales") || game.player.hmPokemon.specie.name.equals("arcanine")) {
                            offsetX++;
                        }
                        if (game.player.hmPokemon.specie.name.equals("ponyta") || game.player.hmPokemon.specie.name.equals("rapidash")) {
                            offsetX += 2;
                        }
                        if (game.player.hmPokemon.specie.name.equals("mamoswine")) {
                            offsetY3 += 5;
                            offsetX += 2;
                        }
                        if (game.player.hmPokemon.specie.name.equals("donphan")) {
                            offsetY3 += 2;
                            offsetX += 2;
                        }
                        if (game.player.hmPokemon.specie.name.equals("rhyhorn")) {
                            offsetY3++;
                            offsetX++;
                        }
                        if (game.player.hmPokemon.specie.name.equals("probopass")) {
                            offsetY3 += 7;
                            offsetX += 2;
                        }
                    } else if (game.player.dirFacing.equals("left")) {
                        offsetX = 0 + 4;
                        if (game.player.hmPokemon.specie.name.equals("ninetales") || game.player.hmPokemon.specie.name.equals("arcanine")) {
                            offsetX--;
                        }
                        if (game.player.hmPokemon.specie.name.equals("ponyta") || game.player.hmPokemon.specie.name.equals("rapidash")) {
                            offsetX -= 2;
                        }
                        if (game.player.hmPokemon.specie.name.equals("mamoswine")) {
                            offsetY3 += 5;
                            offsetX -= 2;
                        }
                        if (game.player.hmPokemon.specie.name.equals("donphan")) {
                            offsetY3 += 2;
                            offsetX -= 2;
                        }
                        if (game.player.hmPokemon.specie.name.equals("rhyhorn")) {
                            offsetY3++;
                            offsetX--;
                        }
                        if (game.player.hmPokemon.specie.name.equals("probopass")) {
                            offsetY3 += 7;
                            offsetX -= 2;
                        }
                    }
                    game.player.hmPokemon.currOwSprite = game.player.hmPokemon.standingSprites.get(game.player.dirFacing);
                    this.spritePart = new Sprite(game.player.hmPokemon.currOwSprite);
                    this.spritePart.setRegionY(game.player.hmPokemon.spriteOffsetY);
                    this.spritePart.setRegionHeight(14);
                    game.mapBatch.draw(this.spritePart, game.player.position.x + ((float) offsetX), game.player.position.y + 10.0f + ((float) offsetY3) + ((float) offsetY) + ((float) pokemonOffsetY));
                    if (game.player.dirFacing.equals("down") && !game.player.hmPokemon.specie.name.equals("rhyhorn") && !game.player.hmPokemon.specie.name.equals("probopass")) {
                        this.spritePart.set(game.player.currSprite);
                        this.spritePart.setRegionY(game.player.spriteOffsetY);
                        this.spritePart.setRegionHeight(8);
                        game.mapBatch.draw(this.spritePart, game.player.position.x, game.player.position.y + 12.0f + ((float) pokemonOffsetY));
                    }
                } else if (game.player.currFieldMove.equals("SURF") && game.player.hmPokemon != null) {
                    this.floatTimer++;
                    if (this.floatTimer > 80 || offsetY < 0) {
                        this.floatTimer = 0;
                    }
                    if (this.floatTimer % 80 == 0) {
                        this.floatOffset = 0;
                    } else if (this.floatTimer % 80 == 40) {
                        this.floatOffset = 1;
                    }
                    int offsetX2 = 0;
                    int offsetY4 = 0;
                    int regionHeight = 14;
                    if (game.player.dirFacing.equals("up")) {
                        offsetY4 = 0 - 1;
                    }
                    if (game.player.dirFacing.equals("down")) {
                        offsetY4 += 2;
                        if (game.player.hmPokemon.specie.name.equals("ludicolo")) {
                            offsetY4 -= 2;
                        }
                    } else if (game.player.dirFacing.equals("right")) {
                        offsetX2 = 0 - 4;
                        if (game.player.hmPokemon.specie.name.equals("raichu")) {
                            offsetX2--;
                        } else if (game.player.hmPokemon.specie.name.equals("pikachu")) {
                            offsetX2--;
                        } else if (game.player.hmPokemon.specie.name.equals("ludicolo")) {
                            offsetX2 += 4;
                        } else if (game.player.hmPokemon.specie.name.equals("sharpedo")) {
                            offsetX2 += 2;
                        }
                    } else if (game.player.dirFacing.equals("left")) {
                        offsetX2 = 0 + 4;
                        if (game.player.hmPokemon.specie.name.equals("raichu")) {
                            offsetX2++;
                        } else if (game.player.hmPokemon.specie.name.equals("pikachu")) {
                            offsetX2++;
                        } else if (game.player.hmPokemon.specie.name.equals("ludicolo")) {
                            offsetX2 -= 4;
                        } else if (game.player.hmPokemon.specie.name.equals("sharpedo")) {
                            offsetX2 -= 2;
                        }
                    }
                    if (game.player.hmPokemon.specie.name.equals("araichu")) {
                        regionHeight = 15;
                        offsetY4 -= 2;
                    } else if (game.player.hmPokemon.specie.name.equals("raichu")) {
                        regionHeight = 15;
                        offsetY4 -= 2;
                    } else if (game.player.hmPokemon.specie.name.equals("pikachu")) {
                        regionHeight = 15;
                        offsetY4 -= 2;
                    }
                    game.player.hmPokemon.currOwSprite = game.player.hmPokemon.standingSprites.get(game.player.dirFacing);
                    this.spritePart.set(game.player.hmPokemon.currOwSprite);
                    this.spritePart.setRegionY(game.player.hmPokemon.spriteOffsetY);
                    this.spritePart.setRegionHeight(regionHeight + this.floatOffset);
                    game.mapBatch.draw(this.spritePart, game.player.position.x + ((float) offsetX2), game.player.position.y + 8.0f + ((float) offsetY4) + ((float) offsetY));
                    if (game.player.dirFacing.equals("down") && !game.player.hmPokemon.specie.name.equals("ludicolo")) {
                        int offsetY5 = 0;
                        if (game.player.hmPokemon.specie.name.equals("lapras")) {
                            offsetY5 = 0 + 3;
                        } else if (game.player.hmPokemon.specie.name.equals("araichu")) {
                            offsetY5 = 0 + 3;
                        } else if (game.player.hmPokemon.specie.name.equals("raichu")) {
                            offsetY5 = 0 + 4;
                        } else if (game.player.hmPokemon.specie.name.equals("pikachu")) {
                            offsetY5 = 0 + 4;
                        }
                        this.spritePart.set(game.player.currSprite);
                        this.spritePart.setRegionHeight((((int) this.spritePart.getHeight()) - 6) + offsetY5 + this.floatOffset);
                        game.mapBatch.draw(this.spritePart, game.player.position.x, game.player.position.y + 4.0f);
                    }
                }
                if (desertGrass) {
                    if (timer < 6) {
                        if (timer == 0) {
                            Player.currGrassOverSprite.setRegion(16, 0, 16, 16);
                            game.insertAction(new PlayMusic("sand2", 0.4f, true, null));
                        }
                        game.mapBatch.draw(Player.currGrassOverSprite, game.player.position.x, game.player.position.y + 7.0f);
                    } else if (timer < 12) {
                        if (timer == 6) {
                            Player.currGrassOverSprite.setRegion(0, 0, 16, 16);
                        }
                        game.mapBatch.draw(Player.currGrassOverSprite, game.player.position.x, game.player.position.y + 7.0f);
                    } else if (timer < 16) {
                        if (timer == 12) {
                            Player.currGrassOverSprite.setRegion(16, 0, 16, 16);
                        }
                        game.mapBatch.draw(Player.currGrassOverSprite, game.player.position.x, game.player.position.y + 7.0f);
                    }
                    if (timer < 16) {
                        timer++;
                    }
                }
            }
        }
    }
}
